@extends('client/layoutIndex')

@section('link')
    <link rel="stylesheet" href="{{ asset('client/css/order.css') }}">
    <script src="http://libs.baidu.com/jquery/1.9.1/jquery.min.js"></script>
    <script src="{{ asset('client/layer/layer.js') }}"></script>
    <script src="{{ asset('client/js/send.js') }}"></script>
@stop

@section('content')
    <span id="msg" style="display: none">
        @if (count($errors) > 0)
            @foreach ($errors->all() as $error)
                <div style="width: 100%;">
                    <span style="color: red;display: block;margin: 0px auto;width: 200px;text-align: center;">{{ $error }}</span>
                </div>
            @endforeach
        @endif
    </span>
    <script type="text/javascript">
        var _msg = $('#msg div span').text();
        console.log(_msg);
        if(_msg != ''){
            layer.msg(_msg);
        }
    </script>
    <div class="order">
        <div class="order-center">
            <div class="step" style="margin-left:30px;">
                <div style="width:30px;height:30px;border-radius:20px;background:#fdb713;
                color:#fff;text-align:center;line-height:30px;float:fixed;position:relative;">
                1</div>
                <span style="width:100px;height:3px;background:#fdb713;display:block;
                margin-left:20px;margin-top:-15px;"></span>
                <div style="width:30px;height:30px;border-radius:20px;background:#fdb713;
                color:#fff;text-align:center;line-height:30px;float:fixed;position:relative;
                margin-left:120px;margin-top:-15px;">2</div>
                <span style="width:100px;height:3px;background:#fdb713;display:block;
                margin-left:140px;margin-top:-17px;"></span>
                <div style="width:30px;height:30px;border-radius:20px;background:#ccc;
                color:grey;text-align:center;line-height:30px;float:fixed;position:relative;
                margin-left:240px;margin-top:-17px;">3</div>
                <span class="font blue" style="margin-left:-15px;"><em>购物车</em></span>
                <span class="line grey"></span>
                <span class="font grey" style="margin-left:65px;"><em>订单信息</em></span>
                <span class="line grey"></span>
                <span class="font grey" style="margin-left:65px;"><em>购物成功</em></span>
                <span class="line grey"></span>
            </div>
            <form method="post" action="{{ url('client/order') }}" enctype="multipart/form-data" class="form-horizontal">
                {{csrf_field()}}
                
                <div class="sm-tit">
                    <h3>请选择收货方式</h3>
                </div>
                <div class="order-sm">
                    <input type="radio" name="way" checked="checked" value="1" onclick="get()">&nbsp;<span style="margin-top:-15px;">自取</span>
                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                    <input type="radio" name="way" value="2" onclick="gift()">&nbsp;邮寄
                </div>
                <div class="order-affirm" id="affirm">
                    <div class="affirm-tit">
                        <h3>确认收货地址</h3>
                    </div>
                    <div class="affirm-address">
                        @if(empty($user['address']))
                            <div class="form-group" style="margin:30px;">
                                <label class="col-md-2 control">收货地址：</label>
                                <div class="col-md-8 col-sm-8 col-xs-8">
                                    <textarea rows="2" style="width:100%;" name="address" placeholder="请如实填写详细收货地址"></textarea>
                                </div>
                            </div>
                        @else
                            <div class="address">
                                <p>{{ $user->address }}</p>
                            </div>
                        @endif
                    </div>
                </div>
                <div class="order-message">
                    <div class="message-tit">
                        <h3>确认订单信息</h3>
                    </div>
                    <div class="fenlei">
                        <div class="fenlei-photo">商品图片</div>
                        <div class="fenlei-name">商品名称</div>
                        <div class="fenlei-price">商品单价</div>
                        <div class="fenlei-count">商品数量</div>
                        <div class="fenlei-total">商品总价</div>
                    </div>
                    @foreach($newCart as $n)
                        <input type="hidden"  name="cid[]" value="{{ $n['id'] }}">
                        <input type="hidden" name="id[{{ $n['id'] }}]" value="{{ $n['goods_id'] }}">
                    <div class="fenlei1">
                        <div class="fenlei-photo1">
                            <img src="/productImg/{{ $n['pic'] }}" style="width:160px;height:160px;">
                        </div>
                        <div class="fenlei-name1">
                           {{ $n['goods_name'] }}
                        </div>
                        <div class="fenlei-price1" id="{{ $n['id'] }}_price">
                            {{ $n['goods_price'] }}
                        </div>
                        <div class="fenlei-count1">
                            {{ $n['goods_num'] }}
                            <input type="hidden" name="num[{{ $n['id'] }}]" value="{{ $n['goods_num'] }}">
                        </div>
                        <div class="fenlei-total1" id="{{ $n['id'] }}_total">
                            {{ $n['goods_num'] * $n['goods_price'] }}
                        </div>
                    </div>
                    @endforeach
                </div>
                <div class="order-so">
                    <div class="order-so-left1" id="codes1">
                        <div class="form-group" style="margin-top:100px;">
                            <label class="col-md-3 col-sm-3 col-xs-3">兑换码：</label>
                            <div class="col-md-5 col-sm-5 col-xs-5">
                                <input type="text" name="code" class="form-control" placeholder="请输入验证码" id="codes" required="required">
                            </div>
                            <div class="col-md-4 col-sm-4 col-xs-4" style="text-align:left;">
                                <input type="text" id="phone" value="{{ Session::get('phone') }}">
                                {{--<a style="height:34px;" onclick="convert();" id="pvc" class="btn btn-default">获取兑换码</a>--}}
                                <input type="button" id="pvc" onclick="convert();" class="btn btn-default" value="获取验证码" />
                            </div>
                        </div>
                        <div class="tishi">
                            商品将于七天之内寄出，请保持手机畅通。
                        </div>
                    </div>
                    <div class="order-so-right">
                        <div style="width:100%;height:100px;">
                            <span style="font-size:20px;font-weight:bold;line-height:100px;">订单总价：</span>
                            <span style="font-size: 25px;"><strong>{{ $total_price }}</strong>积分</span>
                            <input type="hidden" name="total_price" value="{{ $total_price }}">
                        </div>
                        <div style="width:100%;height:140px;line-height:140px;text-align:right;">
                            <a href="{{ url('client/showCart/'.Session::get('uid')) }}" class="">返回购物车</a>
                            &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                            <input type="submit" class="btn btn-danger btn-lg" value="提交订单">&nbsp;&nbsp;&nbsp;
                        </div>
                        
                    </div>
                    
                </div>
            </form>
        </div>
    </div>

    <script>
        $("#codes").attr({"required":false});
        // --选择方式--
        function get(){
             $("#affirm").hide();
              $("#codes1").hide();
              $("#codes").attr({"required":false});
        }
        function gift(){
           $('#affirm').show();
            $('#codes1').show();
            $("#codes").attr({"required":true});
        }
        // --兑换码--
        // --获取手机验证码--
            var time="";
            function pvc(){
                var pvc=document.getElementById("pvc"); 
                time=5;
                setInterval(function(){
                    pvc.innerHTML = +time+"秒后，重新发送兑换码";
                    time--;
                    if(time <= -1){
                        pvc.innerHTML = "重新发送";
                        clearInterval();
                    }
                },1000);    
            }
    </script>



@stop